package one.stand.dto;

import lombok.Builder;
import lombok.Data;

import java.util.Objects;

/**
 * @author cjr
 */
@Data
@Builder
public class UserDto {
    private Integer userId;
    private String name;

    //admin
    private String loginName;
    private Integer sex;
    private String position;
    private Integer tourist;

    //user
    private String phone;
    private String userImg;
    private String unionid;
    private Integer roleId;
    private String province;

    private boolean adminUser;
    private boolean emptyUser;

    public boolean isBoss() {
        return Objects.nonNull(roleId) && roleId > 0;
    }

    public boolean isBoss(Integer companyId) {
        return isBoss() && roleId.equals(companyId);
    }

    public static UserDto empty(Integer id) {
        return UserDto.builder()
                .userId(id)
                .name(null)
                .adminUser(false)
                .emptyUser(true)
                .build();
    }
}
